package com.daiyang.lottery.common.exception;

import com.daiyang.lottery.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

//@Data会生成自己的equals、hashCode方法 可能会缺少父类的属性 所以需要@EqualsAndHashCode(callSuper = true)
@Data

@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {
    /**
     * 异常码
     * @see com.daiyang.lottery.common.errorcode.ServiceErrorCodeConstants
     */

    private Integer code;


    /**
     * 异常信息
     */

    private String message;

    public ServiceException() {

    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }



}
